<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2018/9/9
 * Time: 1:22
 */

namespace app\common\model;

class TeacherBase extends Base{

    const ROOT_PERMISSION = 0;
    const MANAGER_PERMISSION = 1;
    const WATCHER_PERMISSON = 2;

    const INSUFFICIENT_PERMISSION = "权限不够";
    protected $permission;

    public function __construct()
    {
        parent::__construct();
        if($this->token != "none"){
            $result = $this->jwt->decode($this->token);
            $this->permission = $result["data"]->permission;
        }
    }

    public function permissionLevel($use_permission){
        if($use_permission == null){
            echoJson(0,self::INSUFFICIENT_PERMISSION);
        }
        
        if($this->permission <= $use_permission){
            return true;
        }

        echoJson(0,self::INSUFFICIENT_PERMISSION);
    }
}